//
//  UIWindow+BHExtension.m
//  xinlangweibo0621
//
//  Created by boldseas on 2017/6/26.
//  Copyright © 2017年 renbohan. All rights reserved.
//

#import "UIWindow+BHExtension.h"
#import "BHTabBarViewController.h"
#import "BHNewfeatureController.h"

@implementation UIWindow (BHExtension)

- (void)switchRootViewController{
    NSString *key = @"CFBundleVersion";
    NSString *lastVersion = [[NSUserDefaults standardUserDefaults] objectForKey:key];
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[key];
    if ([lastVersion isEqualToString:currentVersion]) {
        BHTabBarViewController *tabbar = [[BHTabBarViewController alloc]init];
        self.rootViewController = tabbar;
    }else{
        BHNewfeatureController *new = [[BHNewfeatureController alloc]init];
        self.rootViewController = new;
        
        [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:key];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

}

@end
